package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2020-02-28 19:14
 */
public class QLint627 {
    public int longestPalindrome(String s) {
        int[] chars = new int[128];
        int one = 0;
        int two = 0;
        for (int i = 0; i < s.length(); i++) {
            chars[s.charAt(i) - 'A']++;
            if(chars[s.charAt(i) - 'A'] == 2) {
                one--;
                chars[s.charAt(i) - 'A'] = 0;
                two++;
            } else {
                one++;
            }
        }

        return (one > 0 ? 1 : 0) + two * 2;
    }
}
